<template>
  <div class="recommend">
    <div class="recommend-item" v-for="item in recommends.slice(0, 4)" :key="item.id">
      <a href="" @click.prevent="goDetail(item.id)">
        <img :src="item.cover_url" alt="" />
        <div>{{item.title}}</div>
      </a>
    </div>
  </div>
</template>

<script>
import {useRouter} from 'vue-router';
export default {
  name: "RecommendView",
  props: {
    recommends: {
      type: Array,
      default() {
        return []
      },
    }
  },
  setup() {
    const router = useRouter();

    const goDetail = (id) => {
      router.push({
        path: '/detail',
        query: {id},
      })
    }


    return {
      goDetail
    }
  },
};
</script>

<style scoped lang="scss">
.recommend {
  width: 100%;
  display: flex;
  text-align: center;
  padding: 15px 0px 15px;
  border-bottom: 1px #EEE solid;
}
.recommend-item {
  flex: 1;
  img {
    width: 80px;
    height: auto;
    margin-bottom: 5px;
  }
  div {
    font-size: 12px;
  }
}
</style>
